<template>
  <div class="user-box">
    <el-button size="mini" @click="dialogVisible = true">新增</el-button>

    <el-dialog
      title="新增"
      :visible.sync="dialogVisible"
      width="35%"
      :before-close="handleClose"
    >
      <!-- 新增用户表单 -->
      <el-form :rules="rules" :inline="true" ref="form" :model="form" label-width="80px">

        <el-form-item prop="name" label="姓名">
          <el-input placeholder="请输入姓名" v-model="form.name"></el-input>
        </el-form-item>

        <el-form-item prop="age" label="年龄">
          <el-input placeholder="请输入年龄" v-model="form.age"></el-input>
        </el-form-item>

        <el-form-item prop="sex" label="性别">
          <el-select v-model="form.sex" placeholder="请选择">
            <el-option label="男" value="1"></el-option>
            <el-option label="女" value="0"></el-option>
          </el-select>
        </el-form-item>

        <el-form-item prop="birth" label="出生日期">
            <el-date-picker
              type="date"
              placeholder="选择日期"
              v-model="form.birth"
            ></el-date-picker>
        </el-form-item>

           <el-form-item prop="addr" label="地址">
          <el-input placeholder="请输入地址" v-model="form.addr"></el-input>
        </el-form-item>
      </el-form>

      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="dialogVisible = false"
          >确 定</el-button
        >
      </span>
    </el-dialog>
  </div>
</template>

<style scoped>
</style>

<script>
export default {
  data() {
    return {
      dialogVisible: false,
      form: {
        name: "",
        age: "",
        sex:'',
        birth:'',
        addr:''
      },
       rules: {
          name: [
            { required: true, message: '请输入姓名', trigger: 'blur' },
          ],
           age: [
            { required: true, message: '请输入年龄', trigger: 'blur' },
          ],
            sex: [
            { required: true, message: '请输入性别', trigger: 'blur' },
          ],
            birth: [
            { required: true, message: '请输入出生日期', trigger: 'blur' },
          ],
            addr: [
            { required: true, message: '请输入地址', trigger: 'blur' },
          ],
        }
    };
  },
};
</script>